package arraysStudy;

import java.util.Arrays;
import java.util.Comparator;

public class PrintMinNumber {

    /**
     * 把数组排成最小的数
     * @param args
     */
    public static void main(String[] args) {

    }

    public String PrintMinNumber(int [] numbers) {
        String[] arr = new String[numbers.length];
        for (int i = 0; i < numbers.length; i++){
            arr[i] = String.valueOf(numbers[i]);
        }
        Arrays.sort(arr, new Comparator<String>() {
            @Override
            public int compare(String x, String y) {
                return (x + y).compareTo((y + x));
            }
        });
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < arr.length; i++){
            sb.append(arr[i]);
        }
        return sb.toString();
    }
}
